#	$Id: epi.mod.mk 6 2006-08-07 19:49:01Z phrakt $
#
# Dynamically Shared Object build definitions
#
# This make include file is loosely inspired from the standard include files
# found in /usr/share/mk

.if exists(${.CURDIR}/../Makefile.inc)
.include "${.CURDIR}/../Makefile.inc"
.endif

OBJS+=		${SRCS:N*.h:R:S/$/.o/g}
DSO?=		${.CURDIR:C/.*\///}
DSOEXT?=	.so
DSOFILE?=	${DSO}${DSOEXT}
DSOCFLAGS?=	-DPIC -fPIC
DSOLDFLAGS?=	-shared


CFLAGS+=	${DSOCFLAGS} ${INCPATH}
LDFLAGS+=	${DSOLDFLAGS}

.if defined(VERSION_MAJOR)
CFLAGS+=	-DVERSION_MAJOR=${VERSION_MAJOR}
.endif
.if defined(VERSION_MINOR)
CFLAGS+=	-DVERSION_MINOR=${VERSION_MINOR}
.endif


.if ${WARNINGS:L} == "yes"
CFLAGS+=	${CDIAGFLAGS}
.endif
CFLAGS+=	${COPTS}


.MAIN: all

all: ${DSOFILE} _SUBDIRUSE

# prefer .S to a .c, add .po, remove stuff not used in the BSD libraries.
# .so used for PIC object files.  .ln used for lint output files.
# .m for objective c files.
.SUFFIXES:
.SUFFIXES: .out .o .go .po .so .S .s .c .C .y .l .ln .m4 .m

.c.o:
	@echo "${COMPILE.c} ${.IMPSRC} -o ${.TARGET}"
	@${COMPILE.c} ${.IMPSRC}  -o ${.TARGET}.o
	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
	@rm -f ${.TARGET}.o

.c.so:
	@echo "${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}"
	@${COMPILE.c} ${PICFLAG} -DPIC ${.IMPSRC} -o ${.TARGET}.o
	@${LD} -x -r ${.TARGET}.o -o ${.TARGET}
	@rm -f ${.TARGET}.o

${DSOFILE}: ${OBJS}
	@echo "THIS IS THE TARGET! LDADD = '${LDADD}' LDFLAGS='${LDFLAGS}'"
	${LD} ${LDFLAGS} ${LDADD} ${PICFLAG} -o ${DSOFILE} ${OBJS}

${DSO}: ${DSOFILE}

clean: _SUBDIRUSE
	${RM} ${OBJS} ${DSOFILE}

cleandir: _SUBDIRUSE clean
	${RM} .depend

install: ${DSOFILE}
	${INSTALL} -o ${MODOWN} -g ${MODGRP} -m ${MODMODE} \
	    ${DSOFILE} ${DESTDIR}${MODDIR}

.include "pf.dep.mk"
.include "pf.subdir.mk"
